<template>
  <div>
    <Search @search="handleSearch" v-slot="{ formData }">
      <el-form-item prop="projectCode" :label="$t('cooperation.projectCode')">
        <el-input v-model="formData.projectCode" :placeholder="$tInput()" />
      </el-form-item>
      <el-form-item prop="projectName" :label="$t('cooperation.projectName')">
        <el-input v-model="formData.projectName" :placeholder="$tInput()" />
      </el-form-item>
    </Search>
    <Table
      ref="table"
      :searchData="searchData"
      :service="services.search"
      @selection-change="handleSelectionChange"
    >
      <template #tools>
        <Tools
          :data="selections"
          @add="handleAdd"
          @edit="handleEdit"
          @remove="handleRemove"
          @download="handleDownload"
          addCode="cooperation:add"
          editCode="cooperation:edit"
          removeCode="cooperation:remove"
          downloadCode="cooperation:download"
        />
      </template>
      <el-table-column
        prop="projectCode"
        :label="$t('cooperation.projectCode')"
      />
      <el-table-column
        prop="projectName"
        :label="$t('cooperation.projectName')"
      />
      <el-table-column
        prop="companyName"
        :label="$t('cooperation.companyName')"
      />
      <el-table-column
        prop="projectCycleName"
        :label="$t('cooperation.projectCycle')"
      />
      <el-table-column
        prop="projectMoney"
        :label="$t('cooperation.projectMoney')"
      />
      <el-table-column prop="peopleNum" :label="$t('cooperation.peopleNum')" />
      <TableColumnAction
        @edit="handleEdit"
        @remove="handleRemove"
        editCode="cooperation:edit"
        removeCode="cooperation:remove"
      />
    </Table>
    <CooperationEdit
      ref="edit"
      :services="services"
      @submit-success="search()"
    />
  </div>
</template>

<script>
import CooperationEdit from './CooperationEdit'
import { crudMixin } from 'mixins'
import { Search, Table, Tools, TableColumnAction } from 'components'
import {
  addCooperation,
  updateCooperation,
  searchCooperation,
  removeCooperation,
  downloadCooperation
} from 'services/school/cooperation'
export default {
  name: 'Cooperation',
  components: {
    Search,
    Table,
    Tools,
    TableColumnAction,
    CooperationEdit
  },
  mixins: [crudMixin],
  data() {
    return {
      services: {
        search: searchCooperation,
        remove: removeCooperation,
        add: addCooperation,
        update: updateCooperation,
        download: downloadCooperation
      }
    }
  }
}
</script>
